package com.lanswon.qzsmk.service.systemManageService;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.client.HttpResponseException;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.exception.InventoryException;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.model.CardControl;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.model.CardTask;
import com.lanswon.qzsmk.model.CooperationCompany;
import com.lanswon.qzsmk.model.PrimaryCardInfo;
import com.lanswon.qzsmk.model.StockDetail;
import com.lanswon.qzsmk.model.StockSum;
import com.lanswon.qzsmk.model.StorageModeDefinition;
import com.lanswon.qzsmk.model.StorageReg;
import com.lanswon.qzsmk.vo.ApplyBatchInfo;
import com.lanswon.qzsmk.vo.DistributeInfo;
import com.lanswon.qzsmk.vo.QueryIncomingAndOutGoing;
import com.lanswon.qzsmk.vo.ResponseCardFileVo;
import com.lanswon.qzsmk.vo.StockSumVo;
import com.lanswon.qzsmk.vo.StorageRegRecVo;
import com.lanswon.qzsmk.vo.StorageRegVo;
import com.mysql.jdbc.exceptions.jdbc4.CommunicationsException;
import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException;

public interface InventoryManagementService {

	/**
	 * 子模块：采购卡入库
	 * 功能：查询返回的制卡文件信息
	 * @param tMap:有四个键值对,是卡批号，制卡供应商，制卡申请日期起，日期止
	 * @return 制卡返回文件的信息
	 * @throws IOException 
	 */
	public DwzPage<ResponseCardFileVo> queryPurchaseCardFiles(Map<String,String> tMap,int currentPage,int pageSize) throws IOException;
	
	/**
	 * 根据选中的文件路径，查询详细的信息框
	 * @param param
	 * @return
	 */
	public Map<String,Object> queryResponseFileDetail(String param);
	
	/**
	 * 解析入库详细信息
	 * @param map
	 * @return
	 */
	public List<Map<String, Object>> getIncomingDetail(Map<String, Object> map);
	
	/**
	 * 根据合作商的单位编号查询合作商
	 * @param companyNo
	 * @return
	 */
	public CooperationCompany CooperationCompanyMapper(String companies);
	
	/**
	 * 入库登记操作
	 * @param companyNo
	 * @return
	 */
	public void incomingRegisterService(String companies);
	
	/**
	 * 查询卡主类型的卡产品名称
	 * @param companyNo
	 * @return
	 */
	public PrimaryCardInfo queryPrimaryCode(String cardPrimaryCode);
	
	/**
	 * 根据制卡文件信息，更新数据库信息
	 * @param serializeForm 表单序列化
	 * @return
	 * @throws InventoryException 
	 * @throws ApplicationException 
	 * @throws HttpResponseException 
	 */
	public Map<String,Object> updateInfo(String serializeForm) throws InventoryException;
	
	/**
	 * 查询
	 * @param cardpCode:卡产品代码，branchNo：网点号，taskNo:任务编号，taskName:任务名称
	 * @return
	 */
	public DwzPage<CardTask> queryTaskInfo(Map<String,String> map,Integer currentPage, Integer numPerPage);
	
	/**
	 * 编辑前画面所选中的信息，编辑map
	 * @param checkedInfo:前画面所选中的配送信息
	 * @return
	 */
	public Map<String, Object> getEditDistributionMap(String checkedInfo);

	/**
	 * sql检索配送的卡片信息
	 * @param taskLists : 任务编号列表
	 * @return
	 */
	public List<CardControl> getDistributeList(List<String> taskLists,List<String> cardPCodeLists);
	
	/**
	 * 配送登记，更新配送信息
	 * @param serializeForm
	 * @return
	 * @throws ApplicationException 
	 * @throws InventoryException 
	 */
	public Map<String, Object> distributeRegistMethod(String serializeForm) throws InventoryException;

	/**
	 * 更具生成任务画面的值进行编辑生成txt文件，存放在服务器上
	 * @param serilizeFormByCreateDis
	 *//*
	public void createDistriTaskFile(String serilizeFormByCreateDis);*/

	/**
	 * 将画面传过来的form表单，转换成map
	 * @param serilizeFormByCreateDis
	 * @return
	 */
	public Map<String, String> getParamMap(String serilizeFormByCreateDis);

	/**
	 * 根据退卡，换卡注销，查询要配送的卡片信息
	 * @param paramMap 画面的查询参数
	 * @return
	 */
	public Map<String, Object> queryDistributeCardInfoByReject(Map<String, String> paramMap);
	
	
	/**
	 * 创建配送任务文件
	 * @param checkedItems
	 */
	public Map<String,String> createDistributeTaskFile(String checkedItems,String branchNo,String taskNo,String empNo);
	
	/**
	 * 模块：网点废卡配送并出库
	 * 功能：查找配送任务的详细信息
	 * @param fileName 任务文件路径
	 * @return map 任务文件信息
	 */
	public Map<String, Object> queryDistributeInfo(String fileName);

	/**
	 * 模块：网点废卡配送并出库
	 * 功能：删除选中的项目(关联到txt中)
	 * @param deleteItems
	 * @param fileName
	 * @return
	 */
	public Map<String, Object> deleteItems(String deleteItems, String fileName,String controlID,String empNo);
	
	/**
	 * 保存配送的废卡信息，跳转到废卡配送页面
	 * @param distributeItem
	 * @return
	 */
	public Map<String, Object> saveDistributeInfo(String[] distributeItem);
	
	/**
	 * 获取出入库流水号等信息
	 * @return
	 */
	public Map<String, Object> getDistributeTaskInfo();
	
	/**
	 * 模块：网点废卡配送并出库
	 * 功能：网点废卡出库登记
	 * @param serializeFormByDistribute
	 * @throws ApplicationException 
	 * @throws InventoryException 
	 */
	public Map<String, Object> submitDistributeTask(String serializeFormByDistribute) throws InventoryException;
	
	/**
	 * 子模块：中心库接收废卡并入库
	 * 功能：查询配送任务的信息
	 * @param map
	 * @param i
	 * @param j
	 * @return
	 */
	public DwzPage<DistributeInfo> queryDistributionRejectCardInfo(Map<String, String> map, int i, int j);
	
	/**
	 * 解析查询配送任务画面的参数并设置流水号
	 * @param checkedItem
	 * @return
	 */
	public Map<String, Object> parseCheckItem(String checkedItem);
	
	/**
	 * 网点配送到中心库接收的DB操作
	 * @param serializeFormByRejIncoming
	 */
	public void dbExecute(String serializeFormByRejIncoming);
	/**
	 * 查询
	 * @param taskNo:任务编号，cardpCode：卡产品代码，
	 * @return
	 */
	public DwzPage<StorageRegRecVo> getCardReceiving(Map<String, String> map, Integer currentPage, Integer numPerPage);
	/**
	 * 查询
	 * @param taskNo:任务编号
	 * @return
	 */
	 List<StorageRegRecVo> querycardReceiving(String taskNo);
	 /**
		 * 网点接收配送登记操作
		 * @param srrv
		 * @return
	 * @throws ApplicationException 
	 * @throws InventoryException 
		 */
	public Map<String,Object> CardReceivingRegist(String paramString) throws InventoryException;
	/**
	 * 获取所有的入库撤销信息
	 * @throws MySQLNonTransientConnectionException 
	 * @throws InventoryException 
	 * @throws CommunicationsException 
	 */
public DwzPage<StorageRegRecVo> queryAllStorageRegs(Map<String, String> map, Integer currentPage, Integer numPerPage) throws Exception;
/**
 * 根据入库流水号查询入库撤销信息
 * @param companyNo
 * @return
 */
 StorageReg queryStorageRegByStorageNo(String storageNo);
 /**
	 * 根据入库登记信息执行入库撤销
	 * @param StorageReg
	 * @return
	 */
public void	 queryStorageReg(StorageReg sr);
/**
 * 根据入库流水号查询库存明细信息
 * @param companyNo
 * @return
 */
 StockDetail queryStockDetailByStorageNo(String storageNo);
 
/**
 * 查询
 * @param storageNo:出库流水号，storageMode：出库方式，storageDate:出库日期起，storageDate1:出库日期止
 * @return
 */
public DwzPage<StorageRegRecVo> queryOutgoingRevcotion(Map<String, String> map, Integer currentPage, Integer numPerPage);
/**
 * 查询
 * @param storageNo:出库流水号
 * @return
 */
StorageRegVo queryOutgoRevoction(String storageNo);
/**
 * 出库撤销登记操作
 * @param ssv
 * @return
 */
public void OutgoingRevocation (StorageRegVo srv);

/**
 * 生成pdf文档
 * @param rMap
 */
public void createStoragePDF(Map<String, Object> rMap);

/**
 * 入库撤销操作
 * @param itemArrays 画面上选中项的值数组
 * @throws ApplicationException 
 * @throws InventoryException 
 */
public void incomingCancelSubmit(String[] itemArrays) throws InventoryException;

/**
 * 上交卡片操作
 * @param 
 */
public Map<String,Object> cardhanding(String[] paramArray);

/**
 * 获取选中的采购卡供应商和文件号
 * @param responseFiletasked
 * @return
 */
public List<Map<String, String>> getMakeCardFileNoList(String[] responseFiletasked);

/**
 * 通过市民卡号查询卡信息
 * @param citizenCardNo
 * @return
 */
public CardData queryCardDataByCitizenNo(String citizenCardNo);

/**
 * 查询空白卡/成品卡上缴记录
 * @param map
 * @param currentPage
 * @param numPerPage
 * @return
 */
public DwzPage<Map<String,String>> getBlankAndFinishCardReceiving(Map<String, String> map, Integer currentPage,
		Integer numPerPage);

/**
 * 空白卡片/成品卡片入库登记
 * @param checkedeParam
 * @return
 */
public Map<String, Object> BlankAndRejectCardReceivingRegist(String checkedeParam,String storageModeByTurnIn);

/**
 * 废卡信息查询
 * @param map
 * @param currentPage
 * @param numPerPage
 * @return
 */
public DwzPage<Map<String, String>> getRejectCardReceiving(Map<String, String> map, Integer currentPage,
		Integer numPerPage);

/**
 * 废卡入库操作
 * @param checkedeParam
 * @return
 * @throws ApplicationException 
 * @throws InventoryException 
 */
public Map<String, Object> RejectCardReceivingRegist(String[] checkedeParam) throws InventoryException;

/**
 * 查询出入库清单列表
 * @param map
 * @param currentPage
 * @param numPerPage
 * @return
 */
public Map<String, Object> getStorageList(Map<String, String> map);


/**
 * 查询，可以领用的卡片信息
 * @param map
 * @param currentPage
 * @param numPerPage
 * @return
 */
public DwzPage<CardTask> getCardInfoByEmpReceive(Map<String, String> map, Integer currentPage, Integer numPerPage);

/**
 * 查询库存定义表所有信息
 * @return
 */
public List<StorageModeDefinition> queryStorageModeDefinition(String storageModeType);

/**
 * 请求卡产品类型，和对应的网点的卡产品库存数量
 * @param cardClassifyDef
 * @param empNo
 * @param empBranch
 * @return
 */
public Map<String, Object> queryCardAmountInfo(String cardClassifyDef, String empNo, String empBranch);

/**
 * 柜员领用登记
 * @param receiveCardPCodeArray
 * @param receivedQuantityArray
 * @param empNo
 * @return
 */
public Map<String, Object> ReceiveCardByEmpRegister(HttpServletRequest request);

/**
 * 检索在库的批量申请批次信息
 * @param request
 * @return
 */
public List<ApplyBatchInfo> queryBatchApplyRecordsByEmpReceive(HttpServletRequest request);

/**
 * 柜员领用时，加载在库批次信息
 * @return
 */
public Map<String,Object> getTaskInfoByEmpReceive();

/**
 * 
 * @param request
 * @return
 */
public Map<String, Object> batchInfoByEmpRegister(String[] checkedItem,String receiveEmpNo);

/**
 * 查询在库的空白和对应的名称
 * @param branchNo
 * @return
 */
public Map<String, List<ApplyBatchInfo>> queryBlankCardAmountInfo(String branchNo);

/**
 * 返回卡片的信息map
 * @param request
 * @return
 */
public Map<String, Object> getReturnCardInfo(HttpServletRequest request);

/**
 * 归还卡片入库登记
 * @param request
 * @return
 */
public Map<String, Object> saveReturnCardRecords(HttpServletRequest request);

/**
 * 盘盈入库登记
 * @param request
 * @return
 */
public Map<String, Object> saveSurplusCardRecords(HttpServletRequest request);

/**
 * 盘库出库
 * @param request
 * @return
 */
public Map<String, Object> saveDeficientOutboundRecords(HttpServletRequest request);

/**
 * 查询库存
 * @param request
 * @return
 */
public List<StockSum> queryStockSum(HttpServletRequest request);

/**
 * 出入库统计（按月）
 * @param request
 * @return
 */
public List<QueryIncomingAndOutGoing> queryIncomingAndOutgoingInfo(HttpServletRequest request);

/**
 * 空白卡上缴
 * @param request
 * @return
 * @throws InventoryException 
 */
public Map<String, Object> cardTurnInRegister(HttpServletRequest request) throws InventoryException;

/**
 * 废卡上缴
 * @param request
 * @return
 * @throws InventoryException 
 */
public Map<String, Object> rejectCardTurnInRegister(HttpServletRequest request) throws InventoryException;

/**
 * 通过市民卡号查询市民卡部分信息
 * @param request
 * @return
 * @throws InventoryException 
 */
public Map<String, Object> queryCardInfoByCitizenCardNo(HttpServletRequest request) throws InventoryException;

/**
 * 查询制卡商
 * @param string
 * @return
 * @throws ApplicationException 
 */
public List<CooperationCompany> queryCooperationCompanyByType(String companyType) throws ApplicationException;

/**
 * 将文件信息加入到页面表单中
 * @param request
 * @return
 * @throws IOException 
 * @throws IllegalStateException 
 */
public Map<String, Object> addReturnFileToPageTable(MultipartFile[] returnFilePath,HttpServletRequest request) throws IllegalStateException, IOException;

/**
 * 将制卡返回文件导入到系统中
 * @param request
 */
public void returnFileImportRegister(HttpServletRequest request);

/**
 * 删除根目录下的文件
 * @param request
 */
public void deleteReturnFileAtRoot(HttpServletRequest request);

/**
 * 查询具体库存的所有卡号
 * @param request
 * @return
 * @throws UnsupportedEncodingException 
 */
public Map<String,Object> queryStockDetailCardInfo(HttpServletRequest request) throws UnsupportedEncodingException;

/**
 * 创建表格清单，供打印预览
 * @param request
 * @throws Exception 
 * @throws Exception 
 */
public Map<String,String> createTableListPDF(HttpServletRequest request) throws Exception, Exception;

/**
 * 检查员工编号是否正确
 * @param request
 * @return
 */
public Map<String, Boolean> checkEmpAndBranch(HttpServletRequest request);

/**
 * 找出对应网点的所有员工的领用和归还记录
 * @param request
 * @return
 */
public Map<String, Object> getRequestAndReturnInfo(HttpServletRequest request);

}
